<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Funcoes{
	
	function converteData($data){
		if (strstr($data, "/")){ // verifica se tem a barra /
        	$d = explode ("/", $data); // tira a barra
           	$rstData = "$d[2]-$d[1]-$d[0]"; // separa as datas $d[2] = ano $d[1] = mes etc...
           	return $rstData;
       	} else if(strstr($data, "-")){
          	$data = substr($data, 0, 10);
          	$d = explode ("-", $data);
          	$rstData = "$d[2]/$d[1]/$d[0]";
          	return $rstData;
       	} else {
          	return '';
      	}
	}
	
	function get_cliente($id){
		$CI = & get_instance();
		$CI->load->model('client_model');

		return $CI->client_model->get_nome($id);
	}
	
	function get_produto($id){
		$CI = & get_instance();
		$CI->load->model('product_model');

		return $CI->product_model->get_nome($id);
	}
}
